#if ((FEATURE_MODE == 2) || (FEATURE_MODE == 0))
/**
 @file sys_usw_sync_ether.h

 @date 2012-10-18

 @version v2.0

*/
#ifndef _SYS_USW_SYNC_ETHER_H
#define _SYS_USW_SYNC_ETHER_H
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************
 *
 * Header Files
 *
 ***************************************************************/
#include "ctc_sync_ether.h"

/***************************************************************
 *
 *  Defines and Macros
 *
 ***************************************************************/

/* DUET2 IS 2; TM IS 3; TMM IS 2; ARCTIC IS 2 */
#define SYS_SYNC_ETHER_CLOCK_MAX 3

/**
 @brief  Define sys layer synce global configure data structure
*/
struct sys_sync_ether_master_s
{
    sal_mutex_t* p_sync_ether_mutex;
    uint8 recovered_clock_lport[SYS_SYNC_ETHER_CLOCK_MAX];
    uint8 rsv;
};
typedef struct sys_sync_ether_master_s sys_sync_ether_master_t;
extern sys_sync_ether_master_t* p_usw_sync_ether_master[CTC_MAX_LOCAL_CHIP_NUM_PP];

#define SYNCE_LOCK \
    if (p_usw_sync_ether_master[lchip]->p_sync_ether_mutex) sal_mutex_lock(p_usw_sync_ether_master[lchip]->p_sync_ether_mutex)
#define SYNCE_UNLOCK \
    if (p_usw_sync_ether_master[lchip]->p_sync_ether_mutex) sal_mutex_unlock(p_usw_sync_ether_master[lchip]->p_sync_ether_mutex)

#define SYS_SYNC_ETHER_INIT_CHECK() \
do { \
    LCHIP_CHECK(lchip);          \
    if (NULL == p_usw_sync_ether_master[lchip]) \
    { \
        return CTC_E_NOT_INIT; \
    } \
} while (0)

#define SYS_SYNC_ETHER_DBG_OUT(level, FMT, ...) \
    do { \
        CTC_DEBUG_OUT(sync_ether, sync_ether, SYNC_ETHER_SYS, level, FMT, ##__VA_ARGS__); \
    } while (0)

/***************************************************************
 *
 *  Functions
 *
 ***************************************************************/
extern int32
sys_usw_sync_ether_init(uint8 lchip);

extern int32
sys_usw_sync_ether_set_cfg(uint8 lchip, uint8 sync_ether_clock_id, ctc_sync_ether_cfg_t* p_sync_ether_cfg);

extern int32
sys_usw_sync_ether_get_cfg(uint8 lchip, uint8 sync_ether_clock_id, ctc_sync_ether_cfg_t* p_sync_ether_cfg);

extern int32
sys_usw_sync_ether_deinit(uint8 lchip);
#ifdef __cplusplus
}
#endif

#endif

#endif

